package com.example.kafka.producer;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.kafka.dsl.Kafka;
import org.springframework.kafka.core.ProducerFactory;


@Configuration
@EnableIntegration
public class ProducerConfig {

    private final ProducerFactory<String, String> producer;


    public ProducerConfig(ProducerFactory<String, String> producer) {
        this.producer = producer;
    }

    @Bean
    public IntegrationFlow produce() {
        return IntegrationFlows.from("kafkaOut")
                .handle(Kafka.outboundChannelAdapter(producer))
                .get();
    }


//    public MessageHandler handler(){
//        KafkaProducerMessageHandler<String,String> handler = new KafkaProducerMessageHandler<>();
//    }
}
